i am working on React-native. and trying to calling a api but i am facing error in json
My error is [SyntaxError: JSON Parse error: Unexpected end of input]
my code is , please
fetch('https://example.com/api/xyz_api.php', {
method: 'POST',
mode: 'no-cors',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
'mail_id': this.state.email_id,
'pass':this.state.pass,
'API_KEY':'API9723887855',
})
}).then((response) => response.json())
.then((json) => {
//this._storeData(json.flag);
console.log(json);
//this.setState({data:json});
if(json.flag == '1')
{
_storeData();
this.props.navigation.navigate('MainScreen');
}
else if(json.flag == '2')
{
this.setState({error:'User not exist'});
this._showDialog();
}
else if(json.flag == '3')
{
this.setState({error:'Incorrect Pasword'});
this._showDialog();
}
}).catch((err) => { console.log(err); });